(function(){
	var AjaxCrud = QualityCheck.AjaxCRUD;
	var serverUrl = QualityCheck.GPUD.ServiceConfig;
	$(function(){
		pageBtns();
		getDetail();
	});
	function pageBtns(){
		$("#back-to-table").unbind("click");
		$("#back-to-table").click(function(){
			$("#detail-show",parent.document).hide();
			$("#right-tables",parent.document).show();
		});
	}
	function getDetail(){
		processBegin("数据加载中······");
		var urlPaStr = $("#detail-show",parent.document).attr("src").split("?")[1];
		var paStr = urlPaStr.split("&");
		var code = paStr[0].split("=")[1];
		var userKey = $("#user-name",parent.parent.parent.document).attr("key");
		var schoolcode = $("#user-name",parent.parent.parent.document).attr("schoolcode");
		var data = {
				cmd:"queryAttendanceRegular",
				model:"attendance",
				userKey:userKey,
				data:{
					currentpage:1,
					pagesize:1,
					schoolcode:schoolcode,
					code:code
				},
				remark:"",
		};
		AjaxCrud.get(serverUrl.ServerLoginUrl,data,function(res){
			if(res.result == 1 && res.data != undefined && res.data != ""){
				if(res.data.data.length > 0){
					processEnd("加载成功");
					showData(res.data.data[0]);
				}else{
				}
			}else{
			}
		},null,null);	
	}
	function showData(data){
		for(var key in data){
			if($("#rule-" + key)[0]){
				if($("#rule-" + key)[0].tagName.toLocaleLowerCase() == "input"){
					if(key == "time"){
						$("#rule-"+key).val(getFormatDateByLong(parseInt(data[key])*1000,"yyyy-MM-dd hh:mm"));
					}else{
						$("#rule-"+key).val(data[key]);
					}
				}else{
					$("#rule-"+key).val(data[key]);
				}
			}
		}
	}
})();